package com.hank.controller;

import com.hank.handler.WebSocketHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author gaoZhiHao
 * @date 2023/4/28 16:48
 */
@RestController
public class DataController {

    @Autowired
    private WebSocketHandler webSocketHandler;

    @PostMapping("/data")
    public String addData(@RequestBody String data) {
        // 新增数据并广播给所有客户端
        webSocketHandler.addData(data);
        return "success";
    }
}
